//
//  ImageViewButton.m
//  03-UIGestureRecognzier
//
//  Created by 曹曹 on 16/7/18.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "ImageViewButton.h"

@implementation ImageViewButton
- (instancetype)initWithFrame:(CGRect)frame backgroundColor:(UIColor *)color image:(NSString *)imageName target:(id)target action:(SEL)action {
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
        imageView.userInteractionEnabled = YES;
        imageView.backgroundColor = color;
        imageView.image = [UIImage imageNamed:imageName];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:target action:action];
        [imageView addGestureRecognizer:tap];
        [self addSubview:imageView];
    }
    return self;
}

@end
